

import java.awt.List;
import java.util.ArrayList;
import java.util.LinkedList;

import engine.Edge;
import engine.Force;
import engine.PhysicsObject;
import engine.Scene;
import engine.Vector;
import engine.Vertex;

import quadTree.QuadTree;
import junit.framework.TestCase;

public class SceneTest extends TestCase {

		
	public static void main(String args[])
	{
		Scene scene = new Scene(100);
		
		QuadTree aTree = scene.getQuadTree();
		assertTrue(aTree!=null);
		
		LinkedList<Vertex> vertList = new LinkedList<Vertex>();
		LinkedList<Edge> edges = new LinkedList<Edge>();
		Vertex vert1 = new Vertex(new Vector(1,1));
		Vertex vert2 = new Vertex(new Vector(2,1));
		Vertex vert3 = new Vertex(new Vector(2,2));
		Vertex vert4 = new Vertex(new Vector(1,2));
		
		vertList.add(vert1);
		vertList.add(vert2);
		vertList.add(vert3);
		vertList.add(vert4);//stationary square
		
		Edge e1 = new Edge(vert1,vert2,20);
		Edge e2 = new Edge(vert2,vert3,20);
		Edge e3 = new Edge(vert3,vert4,20);
		Edge e4 = new Edge(vert4,vert1,20);
		edges.add(e1);
		vert1.addEdge(e1);
		vert2.addEdge(e1);
		edges.add(e2);
		vert2.addEdge(e2);
		vert3.addEdge(e2);
		edges.add(e3);
		vert3.addEdge(e3);
		vert4.addEdge(e3);
		edges.add(e4);
		vert4.addEdge(e4);
		vert1.addEdge(e4);
		
		float mass = 20;
		int index = 0;
		Vector velocity = new Vector(0,0);
		PhysicsObject test = new PhysicsObject(index, vertList, mass, edges, velocity);
		
		scene.addObject(test);
		assertTrue(scene.getObject(0)==test);
		
		PhysicsObject test2 = scene.getObject(0);
		assertTrue(test2==scene.getObject(0));
		
		
		scene.removeObject(test);
		assertTrue(scene.getObjectList()[0]==null);
		
		scene.addObject(test);
		
		Force f1 = new Force(new Vector(1.5f,1.5f), new Vector(4,3), 2);
		Force f2 = new Force(new Vector(1.5f,1.5f), new Vector(4,0), Float.POSITIVE_INFINITY);
		
		scene.addForce(f1);
		assertTrue(scene.getLocalForce(0).equals(f1));
		
		scene.addForce(f2);
		assertTrue(scene.getGlobalForce(0).equals(f2));
		
		scene.removeForce(f1);
		assertTrue(scene.getLocalForce(0)==null);
		
		
		
		
		PhysicsObject[] testing = scene.getObjectList();
		assertTrue(testing.length==5);
		
		scene.update(1, false);
		assertTrue(test.getPosition().getY()==1.5);
		assertTrue(test.getPosition().getX()>1.5);

		scene.changeForceRange(f2, 3);
		assertTrue(scene.getGlobalForce(0)==null);
		assertTrue(scene.getLocalForce(0).equals(f2));
	
	
		scene.setDegradation(.85f);
		assertTrue(scene.getDegradation() == .85f);
		
		
	
	}
	

}
